﻿using System;
using System.ComponentModel;
using System.Management.Instrumentation;

namespace xCarLinkMP3Organizer
{
    public class BaseViewModel : INotifyPropertyChanged, IDisposable
    {
        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        protected void PropChanged(string propName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
        }

        public virtual void Dispose()
        {
        }
    }

    public class Controller
    {
        public static Controller Instance = new Controller();

        private int busyCounter_;
        public bool IsBusy { get; set; }

        public void Execute(Action action)
        {
            busyCounter_++;
            IsBusy = true;
            try
            {
                action();
            }
            finally
            {
                busyCounter_--;
                if (busyCounter_ == 0)
                    IsBusy = false;
            }
        }
    }
}